package com.sikao.app.view;

import android.graphics.Color;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

/**
 * Created by yunjian on 2015/12/16.
 */
public class WindowUtil {
	public static void setUpStatusBarStyle(AppCompatActivity context) {
		if (hasKitKat()) {
			//Translucent status bar透明状态栏
			context.getWindow().setFlags(
					WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
					WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

			// Translucent navigation bar透明导航栏，这里会设置底部虚拟按键透明
			/*context.getWindow().setFlags(
					WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
					WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);*/
		} /*else if (hasLollipop()) {
			Window window = context.getWindow();
			window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
					| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
			View decorView = window.getDecorView();
			int option = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION//这里和底部虚拟按键有问题
					| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
					| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
			decorView.setSystemUiVisibility(option);
			//window.setNavigationBarColor(Color.TRANSPARENT);//这里会设置底部虚拟按键透明
			window.setStatusBarColor(Color.TRANSPARENT);
		}*/
	}

	public static boolean hasKitKat() {
		return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
	}

	public static boolean hasLollipop() {
		return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
	}

}
